package cn.iocoder.yudao.module.brokerage.user.api;

import cn.iocoder.yudao.module.api.brokerage.user.BrokerageUserApi;
import cn.iocoder.yudao.module.api.brokerage.user.vo.BrokerageUserVO;
import cn.iocoder.yudao.module.api.member.vip.vo.VipUserSummaryVO;
import cn.iocoder.yudao.module.brokerage.user.convert.BrokerageUserConvert;
import cn.iocoder.yudao.module.brokerage.user.pojo.po.BrokerageUserDO;
import cn.iocoder.yudao.module.brokerage.user.service.AppBrokerageUserService;
import jakarta.annotation.Nonnull;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;

/**
 * <pre>
 * OOoO0OOoO0OOOooo0oOOOO0OOOOO0oooOO0ooOOO0Ooooo0OOOOo0ooooO0OOooo0Ooooo0OOOOO
 *  这里是文件说明
 * OOoO0OOoO0OOOooo0oOOOO0OOOOO0oooOO0ooOOO0Ooooo0OOOOo0ooooO0OOooo0Ooooo0OOOOO
 * </pre>
 *
 * @author 山野羡民（1032694760@qq.com）
 * @since 2025/01/23
 */
@Service
@Validated
public class BrokerageUserApiImpl implements BrokerageUserApi {
    @Resource
    private AppBrokerageUserService appBrokerageUserService;

    @Nonnull
    @Override
    public BrokerageUserVO getDetail(@Nonnull Long userId) {
        BrokerageUserDO entity = appBrokerageUserService.getOrCreate(userId);
        if (entity == null) {
            BrokerageUserVO respDTO = new BrokerageUserVO();
            respDTO.setUserId(null);
            return respDTO;
        }
        return BrokerageUserConvert.INSTANCE.convert2(entity);
    }

    @Override
    public int getFatherCount(Long userId) {
        return appBrokerageUserService.getFatherCount(userId);
    }

    @Override
    public int getGrandpaCount(Long userId) {
        return appBrokerageUserService.getGrandpaCount(userId);
    }

    @Override
    public VipUserSummaryVO getVipSummary(Long userId) {
        return appBrokerageUserService.getVipSummary(userId);
    }

}
